home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 28
/
Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso
/
Aminet
/
dev
/
lang
/
fpc09905c.lha
/
fpc
/
inc
/
m68k.inc
< prev
next >
Wrap
Text File
|
1998-09-21
|
25KB
|
865 lines
{
$Id: m68k.inc,v 1.10 1998/08/17 12:26:04 carl Exp $
This file is part of the Free Pascal run time library.
Copyright (c) 1993,97 by Carl-Eric Codere,
member of the Free Pascal development team.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
{****************************************************************************
m68k.inc : Processor dependent implementation of system unit
For Motorola 680x0 Processor.
*****************************************************************************}
{****************************************************************************}
{ Credit where credit is due: }
{ -Some of the copy routines taken from the Atari dlib source code: }
{ Dale Schumacher (alias: Dalnefre') dal@syntel.uucp }
{ 399 Beacon Ave. St. Paul, MN 55104,USA }
{ -Some of the routines taken from the freeware ATARI Sozobon C compiler }
{ 1988 by Sozobon, Limited. Author: Johann Ruegg (freeware) }
{ Thanks to all these people wherever they maybe today! }
{****************************************************************************}
{ Don't call the following routines directly. }
Procedure Hlt;[public,alias: 'HALT_ERROR'];
{ called by code generator on run-time errors. }
{ on entry contains d0 = error code. }
var
b:byte; { only byte is used... }
begin
asm
move.b d0,b
end;
HandleError(b);
end;
Procedure FillChar(var x; count: longint; value: byte);
begin
asm
move.l 8(a6), a0 { destination }
move.l 12(a6), d1 { number of bytes to fill }
move.b 16(a6),d0 { fill data }
cmpi.l #65535, d1 { check, if this is a word move }
ble @LMEMSET3 { use fast dbra mode }
bra @LMEMSET2
@LMEMSET1:
move.b d0,(a0)+
@LMEMSET2:
subq.l #1,d1
cmp.b #-1,d1
bne @LMEMSET1
bra @LMEMSET5 { finished slow mode , exit }
@LMEMSET4: { fast loop mode section 68010+ }
move.b d0,(a0)+
@LMEMSET3:
dbra d1,@LMEMSET4
@LMEMSET5:
end ['d0','d1','a0'];
end;
Procedure FillObject(var x; count: longint; value: byte);
begin
asm
move.l 8(a6), a0 { destination }
move.l 12(a6), d1 { number of bytes to fill }
move.w 16(a6),d0 { fill data }
cmp.l #65535, d1 { check, if this is a word move }
ble @LMEMSET3 { use fast dbra mode }
bra @LMEMSET2
@LMEMSET1:
move.b d0,(a0)+
@LMEMSET2:
subq.l #1,d1
cmp.b #-1,d1
bne @LMEMSET1
bra @LMEMSET5 { finished slow mode , exit }
@LMEMSET4: { fast loop mode section 68010+ }
move.b d0,(a0)+
@LMEMSET3:
dbra d1,@LMEMSET4
@LMEMSET5:
end ['d0','d1','a0'];
end;
procedure int_help_constructor;
begin
asm
XDEF HELP_CONSTRUCTOR
{ Entry without preamble, since we need the ESP of the
constructor }
{ Stack (relative to %ebp):
12 Self
8 VMT-Address
4 main programm-Addr
0 %ebp
}
{ do we have to initialize self }
{ we just need to check for zero }
move.l a5,d0
tst.l d0 { set flags }
bne @LHC_4
{ get memory, but save register first }
{ temporary variable }
subq.l #4,sp
move.l sp,a5
{ Save Registers }
movem.l d0-a7,-(sp)
{ Memory size }
move.l 8(a6),a0
move.l (a0),-(sp)
{ push method pointer }
move.l a5,-(sp)
jsr GETMEM
{ Restore all registers in the correct order }
movem.l (sp)+,d0-a7
{ Memory size to a5 }
move.l (a5),a5
add.l #4,sp
{ If no memory available : fail() }
move.l a5,d0
tst.l d0 { set flags for a5 }
beq @LHC_5
{ init self for the constructor }
move.l a5,12(a6)
@LHC_4:
{ is there a VMT address ? }
move.l 8(a6),d0
or.l d0,d0
bne @LHC_7
{ In case the constructor doesn't do anything, the Zero-Flag }
{ can't be put, because this calls Fail() }
add.l #1,d0
rts
@LHC_7:
{ set zero inside the object }
{ Save Registers }
movem.l d0-a7,-(sp)
move.w #0,-(sp)
move.l 8(a6),a0
move.l (a0),-(sp)
move.l a5,-(sp)
{ }
jsr FILLOBJECT
{ Restore all registers in the correct order }
movem.l (sp)+,d0-a7
{ set the VMT address for the new created object }
move.l 8(a6),d0
move.l d0,(a5)
or.l d0,d0
@LHC_5:
rts
end;
end;
procedure help_fail;
begin
asm
end;
end;
procedure int_help_destructor;
begin
asm
{ Stack (relative to %ebp):
12 Self
8 VMT-Address
4 Main program-Addr
0 %ebp
}
{ temporary Variable }
XDEF HELP_DESTRUCTOR
subq.l #4,sp
move.l sp,d6
{ Save Registers }
movem.l d0-a7,-(sp)
move.l 8(a6),d0 { Get the address of the vmt }
or.l d0,d0 { Check if there is a vmt }
beq @LHD_3
{ Yes, get size from SELF! }
move.l 12(a6),a0
{ get VMT-pointer (from Self) to %ebx }
move.l (a0),a1
{ And put size on the Stack }
move.l (a1),-(sp)
{ SELF }
{ I think for precaution }
{ that we should clear the VMT here }
clr.l (a0)
{ get address of local variable into }
{ address register }
move.l d6,a1
move.l a0,(a1)
move.l a1,-(sp)
jsr FREEMEM
@LHD_3:
{ Restore all registers in the correct order }
movem.l (sp)+,d0-a7
add.l #4,sp
rts
end;
end;
procedure new_class;assembler;
asm
XDEF NEW_CLASS
{ create class ? }
move.l 8(a6), d0
tst.l d0
{ check for nil... }
beq @NEW_CLASS1
{ a5 contains vmt }
move.l a5,-(sp)
{ call newinstance (class method!) }
jsr 16(a5)
{ new instance returns a pointer to the new created }
{ instance in d0 }
{ load a5 and insert self }
move.l d0,8(a6)
move.l d0,a5
bra @end
@NEW_CLASS1:
move.l a5,8(a6)
@end:
end;
procedure dispose_class;assembler;
asm
XDEF DISPOSE_CLASS
{ destroy class ? }
move.l 8(a6),d0
{ save self }
move.l a5,8(a6)
tst.l d0
beq @DISPOSE_CLASS
{ no inherited call }
move.l (a5),d0
{ push self }
move.l a5,-(sp)
{ call freeinstance }
move.l d0,a0
jsr 20(a0)
@DISPOSE_CLASS:
{ load self }
move.l 8(a6),a5
end;
{ checks for a correct vmt pointer }
procedure co;assembler;
{ ON ENTRY: a0 -> Pointer to the VMT }
{ Nota: All registers must be preserved including }
{ A0 itself!